﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SaleOnlineSystem.Admin.Controls
{
    public partial class ChangePasswordLogin : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnChangePass_Click(object sender, EventArgs e)
        {
            int user_id = Convert.ToInt32(Request.QueryString["idaccount"]);
            string passworlogin = Session["PasswordAccount"].ToString();
            string passold = txtPassOld.Text;
            string passnew = txtPassNew.Text;
            string passconnew = txtConPassNew.Text;
            if (passold == passworlogin)
            {
                string password_mahoa = LIB.Converter.Encode("sha1", passnew);
                DAL.DHelpers.Column[] cl = new DAL.DHelpers.Column[1];
                cl[0] = new DAL.DHelpers.Column("Account_Password", password_mahoa, DAL.DHelpers.DataType.DataTypeSql.Nvarchar);

                string[] colWhere = new string[1];
                colWhere[0] = "Account_ID";

                object[] colValue = new object[1];
                colValue[0] = user_id;

                DAL.DCollector.DBCollector.Instance.Update("tbl_Account", cl, colWhere, colValue);
                Response.Write("<script>alert('Mật khẩu của bạn đã đc thay đổi...')</script>");
            }
            else
            {
                Response.Write("<script>alert('Mật khẩu cũ không chính xác...')</script>");
            }
        }
    }
}